<!DOCTYPE html>





<html class="theme-next gemini use-motion" lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="generator" content="Hexo 3.9.0">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=7.3.0">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/penguin-32px-next.png?v=7.3.0">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/penguin-16px-next.png?v=7.3.0">
  <link rel="mask-icon" href="/images/logo.svg?v=7.3.0" color="#222">

<link rel="stylesheet" href="/css/main.css?v=7.3.0">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css?v=4.7.0">
  <script src="/lib/pace/pace.min.js?v=1.0.2"></script>
  <link rel="stylesheet" href="/lib/pace/pace-theme-minimal.min.css?v=1.0.2">


<script id="hexo-configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    version: '7.3.0',
    sidebar: {"position":"left","display":"post","offset":12,"onmobile":false},
    back2top: {"enable":true,"sidebar":false,"scrollpercent":true},
    save_scroll: false,
    copycode: {"enable":false,"show_result":false,"style":null},
    fancybox: false,
    mediumzoom: false,
    lazyload: false,
    pangu: false,
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    },
    localsearch: {"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},
    path: 'search.xml',
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    translation: {
      copy_button: '复制',
      copy_success: '复制成功',
      copy_failure: '复制失败'
    }
  };
</script>

  <meta name="keywords" content="RabbitMQ,SpringBoot">
<meta property="og:type" content="article">
<meta property="og:title" content="RabbitMQ详解">
<meta property="og:url" content="https://crazyrico.com/posts/2019/01/09/d6e5ae0b.html">
<meta property="og:site_name" content="疯狂的企鹅">
<meta property="og:locale" content="zh-CN">
<meta property="og:image" content="http://static.nsoft.vip/19-1-9/43486364.jpg">
<meta property="og:image" content="http://static.nsoft.vip/19-1-14/59803987.jpg">
<meta property="og:image" content="http://static.nsoft.vip/19-1-15/6605.jpg">
<meta property="og:updated_time" content="2019-10-16T08:06:47.674Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="RabbitMQ详解">
<meta name="twitter:image" content="http://static.nsoft.vip/19-1-9/43486364.jpg">
  <link rel="alternate" href="/atom.xml" title="疯狂的企鹅" type="application/atom+xml">
  <link rel="canonical" href="https://crazyrico.com/posts/2019/01/09/d6e5ae0b">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome: false,
    isPost: true,
    isPage: false,
    isArchive: false
  };
</script>

  <title>RabbitMQ详解 | 疯狂的企鹅</title>
  








  <noscript>
  <style>
  .use-motion .motion-element,
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-title { opacity: initial; }

  .use-motion .logo,
  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-CN">

  <div class="container sidebar-position-left">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta">

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">疯狂的企鹅</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
        <p class="site-subtitle">Crazy.Rico's Blog</p>
      
  </div>

  <div class="site-nav-toggle">
    <button aria-label="切换导航栏">
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>


<nav class="site-nav">
  
  <ul id="menu" class="menu">
      
      
      
        
        <li class="menu-item menu-item-home">
      
    

    <a href="/" rel="section"><i class="menu-item-icon fa fa-fw fa-home"></i> <br>首页</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-archives">
      
    

    <a href="/archives/" rel="section"><i class="menu-item-icon fa fa-fw fa-archive"></i> <br>归档</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-about">
      
    

    <a href="/about/" rel="section"><i class="menu-item-icon fa fa-fw fa-user"></i> <br>关于</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-tags">
      
    

    <a href="/tags/" rel="section"><i class="menu-item-icon fa fa-fw fa-tags"></i> <br>标签</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-categories">
      
    

    <a href="/categories/" rel="section"><i class="menu-item-icon fa fa-fw fa-th"></i> <br>分类</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-links">
      
    

    <a href="/links/" rel="section"><i class="menu-item-icon fa fa-fw fa-chain"></i> <br>links</a>

  </li>
      <li class="menu-item menu-item-search">
        <a href="javascript:;" class="popup-trigger">
        
          <i class="menu-item-icon fa fa-search fa-fw"></i> <br>搜索</a>
      </li>
    
  </ul>

    <div class="site-search">
      
  <div class="popup search-popup local-search-popup">
  <div class="local-search-header clearfix">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
    <div class="local-search-input-wrapper">
      <input autocomplete="off"
             placeholder="搜索..." spellcheck="false"
             type="text" id="local-search-input">
    </div>
  </div>
  <div id="local-search-result"></div>
</div>


    </div>
</nav>
</div>
    </header>

    

  <a href="https://github.com/crazyrico" class="github-corner" title="Follow me on GitHub" aria-label="Follow me on GitHub" rel="noopener" target="_blank"><svg width="80" height="80" viewBox="0 0 250 250" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a>


    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
            

          <div id="content" class="content page-post-detail">
            

  <div id="posts" class="posts-expand">
    

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://crazyrico.com/posts/2019/01/09/d6e5ae0b.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Crazy Rico">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="http://static.nsoft.vip/penguin.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="疯狂的企鹅">
    </span>
      <header class="post-header">

        
          <h1 class="post-title" itemprop="name headline">RabbitMQ详解

            
          </h1>
        

        <div class="post-meta">
		   
		  <!-- add by alex.yao 2019-10-17 begin -->
		   
		  <!-- add by alex.yao 2019-10-17 end -->
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              
                
              

              <time title="创建时间：2019-01-09 13:33:02" itemprop="dateCreated datePublished" datetime="2019-01-09T13:33:02+08:00">2019-01-09</time>
            </span>
          
            

            
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2019-10-16 16:06:47" itemprop="dateModified" datetime="2019-10-16T16:06:47+08:00">2019-10-16</time>
              </span>
            
          
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/高性能架构/" itemprop="url" rel="index"><span itemprop="name">高性能架构</span></a></span>

                
                
                  ，
                
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/高性能架构/RabbitMQ/" itemprop="url" rel="index"><span itemprop="name">RabbitMQ</span></a></span>

                
                
              
            </span>
          

          
            <span class="post-meta-item" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="busuanzi-value" id="busuanzi_value_page_pv"></span>
            </span>
          
          <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="fa fa-file-word-o"></i>
              </span>
              
                <span class="post-meta-item-text">本文字数：</span>
              
              <span>7.5k</span>
            </span>
          
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="fa fa-clock-o"></i>
              </span>
              
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              
              <span>7 分钟</span>
            </span>
          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <p><img src="http://static.nsoft.vip/19-1-9/43486364.jpg" alt=""></p>
<a id="more"></a>

<h1 id="初识RabbitMQ"><a href="#初识RabbitMQ" class="headerlink" title="初识RabbitMQ"></a>初识RabbitMQ</h1><p>RabbitMQ是一个开源的消息代理和队列服务器，用来通过普通协议在完全不同的应用之间共享数据，RabbitMQ是使用Erlang语言编写的，并且RabbitMQ是基于AMQP协议的。</p>
<ul>
<li>目前很多互联网大厂都在使用RabbitMQ</li>
<li>RabbitMQ底层使用Erlang语言编写</li>
<li>开源、性能优秀、稳定性保障</li>
<li>与SpringAMQP完美整合、API丰富</li>
<li>集群模式丰富，表达式配置，HA模式，镜像队列模式</li>
<li>保证数据不丢失的前提做到高可用性，高可靠性</li>
<li>AMQP全称：Advanced Message Queuing Protocol(高级消息队列协议)</li>
</ul>
<h1 id="AMQP协议模型"><a href="#AMQP协议模型" class="headerlink" title="AMQP协议模型"></a>AMQP协议模型</h1><p><img src="http://static.nsoft.vip/19-1-14/59803987.jpg" alt=""></p>
<h1 id="AMQP核心概论"><a href="#AMQP核心概论" class="headerlink" title="AMQP核心概论"></a>AMQP核心概论</h1><p><strong>Virtual host</strong>: 虚拟地址，用于进行逻辑隔离，最上层的消息路由。一个Virtual Host里面可以有若干个Exchange和Queue，同时一个Virtual Host里面不能有相同名称的Exchange和Queue</p>
<p><strong>Exchange</strong>: 交换机，接收消息，根据路由键转发消息到绑定的队列</p>
<p><strong>Binding</strong>: Exchange和Queue之间的虚拟连接，binding中可以包含routing key</p>
<p><strong>Routing key</strong>: 一个路由规则，虚拟机可用它来确定如何路由一个特定消息</p>
<p><strong>Queue</strong>: 也称为Message Queue，消息队列，保存消息并将它们转发给消费者</p>
<h1 id="RabbitMQ消息流转"><a href="#RabbitMQ消息流转" class="headerlink" title="RabbitMQ消息流转"></a>RabbitMQ消息流转</h1><p><img src="http://static.nsoft.vip/19-1-15/6605.jpg" alt=""></p>
<h1 id="RabbitMQ整合SpringBoot2-x"><a href="#RabbitMQ整合SpringBoot2-x" class="headerlink" title="RabbitMQ整合SpringBoot2.x"></a>RabbitMQ整合SpringBoot2.x</h1><p>SpringBoot与RabbitMQ集成非常简单，不需要任何额外设置只需要两步即可：</p>
<h2 id="引入相关依赖"><a href="#引入相关依赖" class="headerlink" title="引入相关依赖"></a>引入相关依赖</h2><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">&lt;dependency&gt;</span><br><span class="line">    &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;</span><br><span class="line">    &lt;artifactId&gt;spring-boot-starter-amqp&lt;/artifactId&gt;</span><br><span class="line">&lt;/dependency&gt;</span><br></pre></td></tr></tbody></table></figure>

<h2 id="配置application-properties"><a href="#配置application-properties" class="headerlink" title="配置application.properties"></a>配置application.properties</h2><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># rabbitmq服务地址</span></span><br><span class="line">spring.rabbitmq.addresses=192.168.8.193:5672</span><br><span class="line"><span class="comment"># rabbitmq用户名密码</span></span><br><span class="line">spring.rabbitmq.username=admin</span><br><span class="line">spring.rabbitmq.password=admin</span><br><span class="line"><span class="comment"># 虚拟地址</span></span><br><span class="line">spring.rabbitmq.virtual-host=/</span><br><span class="line"><span class="comment"># 超时设置</span></span><br><span class="line">spring.rabbitmq.connection-timeout=15000</span><br></pre></td></tr></tbody></table></figure>

<h2 id="代码配置"><a href="#代码配置" class="headerlink" title="代码配置"></a>代码配置</h2><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br></pre></td><td class="code"><pre><span class="line">package com.marspie.config;</span><br><span class="line"></span><br><span class="line">import org.springframework.amqp.core.*;</span><br><span class="line">import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;</span><br><span class="line">import org.springframework.amqp.rabbit.connection.ConnectionFactory;</span><br><span class="line">import org.springframework.context.annotation.Bean;</span><br><span class="line">import org.springframework.context.annotation.Configuration;</span><br><span class="line"></span><br><span class="line">/**</span><br><span class="line"> * Copyright (c) 2019, The Marspie Open Source Project</span><br><span class="line"> * 配置方法一： application.properties</span><br><span class="line"> * 配置方法二: 代码配置ConnectionFactory</span><br><span class="line"> * @author alex</span><br><span class="line"> * @date 2019/1/11 11 32</span><br><span class="line"> * @email yaonew@126.com</span><br><span class="line"> * @blog http://nsoft.vip</span><br><span class="line"> * Licensed under the Apache License, Version 2.0 (the <span class="string">"License"</span>);</span><br><span class="line"> * you may not use this file except <span class="keyword">in</span> compliance with the License.</span><br><span class="line"> * You may obtain a copy of the License at</span><br><span class="line"> * &lt;p&gt;</span><br><span class="line"> * http://www.apache.org/licenses/LICENSE-2.0</span><br><span class="line"> * &lt;p&gt;</span><br><span class="line"> * Unless required by applicable law or agreed to <span class="keyword">in</span> writing, software</span><br><span class="line"> * distributed under the License is distributed on an <span class="string">"AS IS"</span> BASIS,</span><br><span class="line"> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span><br><span class="line"> * See the License <span class="keyword">for</span> the specific language governing permissions and</span><br><span class="line"> * limitations under the License.</span><br><span class="line"> */</span><br><span class="line">@Configuration</span><br><span class="line">public class RabbitMqConfig {</span><br><span class="line"></span><br><span class="line">/*    @Bean</span><br><span class="line">    public ConnectionFactory <span class="function"><span class="title">connectionFactory</span></span>() {</span><br><span class="line">        CachingConnectionFactory connectionFactory = new CachingConnectionFactory();</span><br><span class="line">        connectionFactory.setAddresses(<span class="string">"192.168.48.51:5672"</span>);</span><br><span class="line">        connectionFactory.setUsername(<span class="string">"admin"</span>);</span><br><span class="line">        connectionFactory.setPassword(<span class="string">"admin"</span>);</span><br><span class="line">        connectionFactory.setVirtualHost(<span class="string">"/"</span>);</span><br><span class="line">        connectionFactory.setPublisherConfirms(<span class="literal">true</span>);//消息确认</span><br><span class="line">        connectionFactory.setPublisherReturns(<span class="literal">true</span>);</span><br><span class="line">        <span class="built_in">return</span> connectionFactory;</span><br><span class="line">    }*/</span><br><span class="line"></span><br><span class="line">    //topic</span><br><span class="line">    public static final String TOPIC_QUEUE1 = <span class="string">"topic.queue1"</span>;</span><br><span class="line">    public static final String TOPIC_QUEUE2 = <span class="string">"topic.queue2"</span>;</span><br><span class="line">    public static final String TOPIC_EXCHANGE = <span class="string">"topic.exchange"</span>;</span><br><span class="line">    // routingKey</span><br><span class="line">    public static final String TOPIC_ROUTING_KEY1 = <span class="string">"order.message"</span>;</span><br><span class="line">    public static final String TOPIC_ROUTING_KEY2 = <span class="string">"order.#"</span>;</span><br><span class="line"></span><br><span class="line">    //fanout</span><br><span class="line">    public static final String FANOUT_QUEUE1 = <span class="string">"fanout.queue1"</span>;</span><br><span class="line">    public static final String FANOUT_QUEUE2 = <span class="string">"fanout.queue2"</span>;</span><br><span class="line">    public static final String FANOUT_EXCHANGE = <span class="string">"fanout.exchange"</span>;</span><br><span class="line"></span><br><span class="line">    //redirect模式</span><br><span class="line">    public static final String DIRECT_QUEUE1 = <span class="string">"direct.queue1"</span>;</span><br><span class="line">    public static final String DIRECT_EXCHANGE = <span class="string">"direct.exchange"</span>;</span><br><span class="line">    public static final String DIRECT_QUEUE2 =<span class="string">"direct.queue2"</span> ;</span><br><span class="line">    // routingKey</span><br><span class="line">    public static final String DIRECT_ROUTING_KEY = <span class="string">"direct.order"</span>;</span><br><span class="line"></span><br><span class="line">    /**</span><br><span class="line">     * Topic模式</span><br><span class="line">     * 将路由键和某模式进行匹配。此时队列需要绑定要一个模式上。符号“<span class="comment">#”匹配一个或多个词，符号“*”匹配不多不少一个词。</span></span><br><span class="line">     * 因此“order.<span class="comment">#”能够匹配到“order.irs.corporate”，但是“order.*” 只会匹配到“order.irs”。</span></span><br><span class="line">     * @<span class="built_in">return</span></span><br><span class="line">     */</span><br><span class="line">    @Bean</span><br><span class="line">    public Queue <span class="function"><span class="title">topicQueue1</span></span>() {</span><br><span class="line">        <span class="built_in">return</span> new Queue(TOPIC_QUEUE1);</span><br><span class="line">    }</span><br><span class="line"></span><br><span class="line">    @Bean</span><br><span class="line">    public Queue <span class="function"><span class="title">topicQueue2</span></span>() {</span><br><span class="line">        <span class="built_in">return</span> new Queue(TOPIC_QUEUE2);</span><br><span class="line">    }</span><br><span class="line"></span><br><span class="line">    @Bean</span><br><span class="line">    public TopicExchange <span class="function"><span class="title">topicExchange</span></span>() {</span><br><span class="line">        <span class="built_in">return</span> new TopicExchange(TOPIC_EXCHANGE);</span><br><span class="line">    }</span><br><span class="line"></span><br><span class="line">    @Bean</span><br><span class="line">    public Binding <span class="function"><span class="title">topicBinding1</span></span>() {</span><br><span class="line">        <span class="built_in">return</span> BindingBuilder.bind(topicQueue1()).to(topicExchange()).with(TOPIC_ROUTING_KEY1);</span><br><span class="line">    }</span><br><span class="line"></span><br><span class="line">    @Bean</span><br><span class="line">    public Binding <span class="function"><span class="title">topicBinding2</span></span>() {</span><br><span class="line">        <span class="built_in">return</span> BindingBuilder.bind(topicQueue2()).to(topicExchange()).with(TOPIC_ROUTING_KEY2);</span><br><span class="line">    }</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    /**</span><br><span class="line">     * Fanout模式</span><br><span class="line">     * Fanout 就是我们熟悉的广播模式或者订阅模式，给Fanout交换机发送消息，绑定了这个交换机的所有队列都收到这个消息。</span><br><span class="line">     * @<span class="built_in">return</span></span><br><span class="line">     */</span><br><span class="line">    @Bean</span><br><span class="line">    public Queue <span class="function"><span class="title">fanoutQueue1</span></span>() {</span><br><span class="line">        <span class="built_in">return</span> new Queue(FANOUT_QUEUE1);</span><br><span class="line">    }</span><br><span class="line"></span><br><span class="line">    @Bean</span><br><span class="line">    public Queue <span class="function"><span class="title">fanoutQueue2</span></span>() {</span><br><span class="line">        <span class="built_in">return</span> new Queue(FANOUT_QUEUE2);</span><br><span class="line">    }</span><br><span class="line"></span><br><span class="line">    @Bean</span><br><span class="line">    public FanoutExchange <span class="function"><span class="title">fanoutExchange</span></span>() {</span><br><span class="line">        <span class="built_in">return</span> new FanoutExchange(FANOUT_EXCHANGE);</span><br><span class="line">    }</span><br><span class="line"></span><br><span class="line">    @Bean</span><br><span class="line">    public Binding <span class="function"><span class="title">fanoutBinding1</span></span>() {</span><br><span class="line">        <span class="built_in">return</span> BindingBuilder.bind(fanoutQueue1()).to(fanoutExchange());</span><br><span class="line">    }</span><br><span class="line"></span><br><span class="line">    @Bean</span><br><span class="line">    public Binding <span class="function"><span class="title">fanoutBinding2</span></span>() {</span><br><span class="line">        <span class="built_in">return</span> BindingBuilder.bind(fanoutQueue2()).to(fanoutExchange());</span><br><span class="line">    }</span><br><span class="line"></span><br><span class="line">    /**</span><br><span class="line">     * direct模式</span><br><span class="line">     * 消息中的路由键（routing key）如果和 Binding 中的 binding key 一致， 交换器就将消息发到对应的队列中。路由键与队列名完全匹配.</span><br><span class="line">     * 这是一个完整的匹配。如果一个队列绑定到该交换机上要求路由键 “<span class="built_in">test</span>”，则只有被标记为“<span class="built_in">test</span>”的消息才被转发，不会转发test.aaa，也不会转发dog.bbb，只会转发<span class="built_in">test</span>。</span><br><span class="line">     * @<span class="built_in">return</span></span><br><span class="line">     */</span><br><span class="line">    @Bean</span><br><span class="line">    public Queue <span class="function"><span class="title">directQueue1</span></span>() {</span><br><span class="line">        <span class="built_in">return</span> new Queue(DIRECT_QUEUE1);</span><br><span class="line">    }</span><br><span class="line"></span><br><span class="line">    @Bean</span><br><span class="line">    public DirectExchange <span class="function"><span class="title">directExchange</span></span>() {</span><br><span class="line">        <span class="built_in">return</span> new DirectExchange(DIRECT_EXCHANGE);</span><br><span class="line">    }</span><br><span class="line"></span><br><span class="line">    @Bean</span><br><span class="line">    public Binding <span class="function"><span class="title">directBinding1</span></span>() {</span><br><span class="line">        <span class="built_in">return</span> BindingBuilder.bind(directQueue1()).to(directExchange()).with(DIRECT_ROUTING_KEY);</span><br><span class="line">    }</span><br><span class="line">}</span><br></pre></td></tr></tbody></table></figure>

<h3 id="Topic模式"><a href="#Topic模式" class="headerlink" title="Topic模式"></a>Topic模式</h3><p>将路由键和某模式进行匹配。此时队列需要绑定要一个模式上。符号“#”匹配一个或多个词，符号“*”匹配不多不少一个词。 因此“order.#”能够匹配到“order.irs.corporate”，但是“order.*” 只会匹配到“order.irs”。</p>
<p>-生产者 </p>
<figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">@Component</span><br><span class="line">public class TopicSender {</span><br><span class="line">    @Autowired</span><br><span class="line">    private AmqpTemplate rabbitTemplate;</span><br><span class="line"></span><br><span class="line">    public void send(Order order) {</span><br><span class="line">        this.rabbitTemplate.convertAndSend(RabbitMqConfig.TOPIC_EXCHANGE,<span class="string">"order.message"</span>, order);</span><br><span class="line">        this.rabbitTemplate.convertAndSend(RabbitMqConfig.TOPIC_EXCHANGE,<span class="string">"order.ha"</span>, order);</span><br><span class="line">    }</span><br><span class="line">}</span><br></pre></td></tr></tbody></table></figure>

<p>-消费者</p>
<figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">@Component</span><br><span class="line">public class TopicReceiver {</span><br><span class="line">    // queues是指要监听的队列的名字</span><br><span class="line">    @RabbitListener(queues = RabbitMqConfig.TOPIC_QUEUE1)</span><br><span class="line">    public void receiveTopic1(Order order) {</span><br><span class="line">        System.out.println(<span class="string">"【receiveTopic1监听到消息】"</span> + order);</span><br><span class="line">    }</span><br><span class="line">    @RabbitListener(queues = RabbitMqConfig.TOPIC_QUEUE2)</span><br><span class="line">    public void receiveTopic2(Order order) {</span><br><span class="line">        System.out.println(<span class="string">"【receiveTopic2监听到消息】"</span> + order);</span><br><span class="line">    }</span><br><span class="line">}</span><br></pre></td></tr></tbody></table></figure>

<h3 id="Fanout模式"><a href="#Fanout模式" class="headerlink" title="Fanout模式"></a>Fanout模式</h3><p>Fanout 就是我们熟悉的广播模式或者订阅模式，给Fanout交换机发送消息，绑定了这个交换机的所有队列都收到这个消息。<br>-生产者 </p>
<figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">@Component</span><br><span class="line">public class FanoutSender {</span><br><span class="line"></span><br><span class="line">    @Autowired</span><br><span class="line">    private AmqpTemplate rabbitTemplate;</span><br><span class="line"></span><br><span class="line">    public void send(Order order) {</span><br><span class="line">        this.rabbitTemplate.convertAndSend(RabbitMqConfig.FANOUT_EXCHANGE, <span class="string">""</span>, order);</span><br><span class="line">    }</span><br><span class="line">}</span><br></pre></td></tr></tbody></table></figure>

<p>-消费者</p>
<figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">@Component</span><br><span class="line">public class FanoutReceiver {</span><br><span class="line"></span><br><span class="line">    // queues是指要监听的队列的名字</span><br><span class="line">    @RabbitListener(queues = RabbitMqConfig.FANOUT_QUEUE1)</span><br><span class="line">    public void receiveTopic1(Order order) {</span><br><span class="line">        System.out.println(<span class="string">"【receiveFanout1监听到消息】"</span> + order);</span><br><span class="line">    }</span><br><span class="line"></span><br><span class="line">    @RabbitListener(queues = RabbitMqConfig.FANOUT_QUEUE2)</span><br><span class="line">    public void receiveTopic2(Order order) {</span><br><span class="line">        System.out.println(<span class="string">"【receiveFanout2监听到消息】"</span> + order);</span><br><span class="line">    }</span><br><span class="line">}</span><br></pre></td></tr></tbody></table></figure>

<h3 id="direct模式"><a href="#direct模式" class="headerlink" title="direct模式"></a>direct模式</h3><p>消息中的路由键（routing key）如果和 Binding 中的 binding key 一致， 交换器就将消息发到对应的队列中。路由键与队列名完全匹配.这是一个完整的匹配。如果一个队列绑定到该交换机上要求路由键 “test”，则只有被标记为“test”的消息才被转发，不会转发test.aaa，也不会转发dog.bbb，只会转发test。<br>-生产者 </p>
<figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">@Component</span><br><span class="line">public class DirectSender {</span><br><span class="line"></span><br><span class="line">    @Autowired</span><br><span class="line">    private RabbitTemplate rabbitTemplate;</span><br><span class="line"></span><br><span class="line">    public void send(Order order) {</span><br><span class="line">        this.rabbitTemplate.convertAndSend(RabbitMqConfig.DIRECT_EXCHANGE, <span class="string">"direct.order"</span>, order);</span><br><span class="line">    }</span><br><span class="line">}</span><br></pre></td></tr></tbody></table></figure>

<p>-消费者</p>
<figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">@Component</span><br><span class="line">public class DirectReceiver {</span><br><span class="line">    // queues是指要监听的队列的名字</span><br><span class="line">    @RabbitListener(queues = RabbitMqConfig.DIRECT_QUEUE1)</span><br><span class="line">    public void receiveDirect1(Order order) {</span><br><span class="line">        System.out.println(<span class="string">"【receiveDirect1监听到消息】"</span> + order);</span><br><span class="line">    }</span><br><span class="line"></span><br><span class="line">    @RabbitListener(queues = RabbitMqConfig.DIRECT_QUEUE1)</span><br><span class="line">    public void receiveDirect2(Order order) {</span><br><span class="line">        System.out.println(<span class="string">"【receiveDirect2监听到消息】"</span> + order);</span><br><span class="line">    }</span><br><span class="line"></span><br><span class="line">}</span><br></pre></td></tr></tbody></table></figure>

<p><a href="https://github.com/yaonew/spring-boot" target="_blank" rel="noopener">GitHub源码</a><br><a href="https://gitee.com/yaonew/spring-boot" target="_blank" rel="noopener">码云源码</a></p>
<script>
        document.querySelectorAll('.github-emoji')
          .forEach(el => {
            if (!el.dataset.src) { return; }
            const img = document.createElement('img');
            img.style = 'display:none !important;';
            img.src = el.dataset.src;
            img.addEventListener('error', () => {
              img.remove();
              el.style.color = 'inherit';
              el.style.backgroundImage = 'none';
              el.style.background = 'none';
            });
            img.addEventListener('load', () => {
              img.remove();
            });
            document.body.appendChild(img);
          });
      </script>
    </div>

    
    
    
	
	<!-- add by alex.yao 2019-08-07 begin -->
	<div>
    
      <!-- add 2018-12-29 -->
<div>
    
        <div style="text-align:center;color: #ccc;font-size:14px;">-------------本文结束<i class="fa fa-paw"></i>感谢您的阅读-------------</div>
    
</div>
    
    </div>
    <!-- add by alex.yao 2019-08-07 end -->
      <div id="wechat_subscriber" style="display: block; padding: 10px 0; margin: 20px auto; width: 100%; text-align: center;">
  <img id="wechat_subscriber_qcode" src="http://static.nsoft.vip/qrcode_for_tec.jpg" alt="Crazy Rico wechat" style="width: 200px; max-width: 100%;">
  <div>欢迎您扫一扫上面的微信公众号，订阅我的博客！</div>
</div>

    
      <div>
        <div id="reward-container">
  <div></div>
  <button id="reward-button" disable="enable" onclick="var qr = document.getElementById(&quot;qr&quot;); qr.style.display = (qr.style.display === 'none') ? 'block' : 'none';">
    打赏
  </button>
  <div id="qr" style="display: none;">
        
      
      <div style="display: inline-block">
        <img src="http://static.nsoft.vip/weixin.png" alt="Crazy Rico 微信支付">
        <p>微信支付</p>
      </div>
        
      
      <div style="display: inline-block">
        <img src="http://static.nsoft.vip/alipay.jpg" alt="Crazy Rico 支付宝">
        <p>支付宝</p>
      </div>

  </div>
</div>

      </div>

    <footer class="post-footer">
          
        
        <div class="post-tags">
            <a href="/tags/RabbitMQ/" rel="tag"># RabbitMQ</a>
          
            <a href="/tags/SpringBoot/" rel="tag"># SpringBoot</a>
          
        </div>
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
              <a href="/posts/2018/12/30/8b3704c2.html" rel="next" title="2018年度账单">
                <i class="fa fa-chevron-left"></i> 2018年度账单
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
              <a href="/posts/2019/03/07/3bca66de.html" rel="prev" title="centos7安装mariadb集群">
                centos7安装mariadb集群 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
    </footer>
  </div>
  
  
  
  </article>

  </div>


          </div>
          
    
    <div class="comments" id="gitalk-container"></div>
  


        </div>
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-overview">

          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image"
      src="http://static.nsoft.vip/penguin.png"
      alt="Crazy Rico">
  <p class="site-author-name" itemprop="name">Crazy Rico</p>
  <div class="site-description motion-element" itemprop="description"></div>
</div>
  <nav class="site-state motion-element">
      <div class="site-state-item site-state-posts">
        
          <a href="/archives/">
        
          <span class="site-state-item-count">33</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
    
      
      
      <div class="site-state-item site-state-categories">
        
          
            <a href="/categories/">
          
        
        
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
        <span class="site-state-item-count">17</span>
        <span class="site-state-item-name">分类</span>
        </a>
      </div>
    
      
      
      <div class="site-state-item site-state-tags">
        
          
            <a href="/tags/">
          
        
        
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
        <span class="site-state-item-count">39</span>
        <span class="site-state-item-name">标签</span>
        </a>
      </div>
    
  </nav>
  <div class="feed-link motion-element">
    <a href="/atom.xml" rel="alternate">
      <i class="fa fa-rss"></i>RSS
    </a>
  </div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
      
      
        
      
      
        
      
        <a href="https://github.com/crazyrico" title="GitHub &rarr; https://github.com/crazyrico" rel="noopener" target="_blank"><i class="fa fa-fw fa-github"></i>GitHub</a>
      </span>
    
      <span class="links-of-author-item">
      
      
        
      
      
        
      
        <a href="https://www.freecodecamp.cn/crazyrico" title="FCC &rarr; https://www.freecodecamp.cn/crazyrico" rel="noopener" target="_blank"><i class="fa fa-fw fa-globe"></i>FCC</a>
      </span>
    
      <span class="links-of-author-item">
      
      
        
      
      
        
      
        <a href="mailto:crazyrico@qq.com" title="E-Mail &rarr; mailto:crazyrico@qq.com" rel="noopener" target="_blank"><i class="fa fa-fw fa-envelope"></i>E-Mail</a>
      </span>
    
      <span class="links-of-author-item">
      
      
        
      
      
        
      
        <a href="https://s.imooc.com/ACFNlyI" title="慕课网 &rarr; https://s.imooc.com/ACFNlyI" rel="noopener" target="_blank"><i class="fa fa-fw fa-fire"></i>慕课网</a>
      </span>
    
      <span class="links-of-author-item">
      
      
        
      
      
        
      
        <a href="https://promotion.aliyun.com/ntms/yunparter/invite.html?userCode=gr9asv3c" title="阿里云 &rarr; https://promotion.aliyun.com/ntms/yunparter/invite.html?userCode=gr9asv3c" rel="noopener" target="_blank"><i class="fa fa-fw fa-cloud"></i>阿里云</a>
      </span>
    
  </div>



        </div>
      </div>
      <!--noindex-->
        <div class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
            
            
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#初识RabbitMQ"><span class="nav-number">1.</span> <span class="nav-text">初识RabbitMQ</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#AMQP协议模型"><span class="nav-number">2.</span> <span class="nav-text">AMQP协议模型</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#AMQP核心概论"><span class="nav-number">3.</span> <span class="nav-text">AMQP核心概论</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#RabbitMQ消息流转"><span class="nav-number">4.</span> <span class="nav-text">RabbitMQ消息流转</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#RabbitMQ整合SpringBoot2-x"><span class="nav-number">5.</span> <span class="nav-text">RabbitMQ整合SpringBoot2.x</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#引入相关依赖"><span class="nav-number">5.1.</span> <span class="nav-text">引入相关依赖</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#配置application-properties"><span class="nav-number">5.2.</span> <span class="nav-text">配置application.properties</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#代码配置"><span class="nav-number">5.3.</span> <span class="nav-text">代码配置</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#Topic模式"><span class="nav-number">5.3.1.</span> <span class="nav-text">Topic模式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Fanout模式"><span class="nav-number">5.3.2.</span> <span class="nav-text">Fanout模式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#direct模式"><span class="nav-number">5.3.3.</span> <span class="nav-text">direct模式</span></a></li></ol></li></ol></li></ol></div>
            

          </div>
        </div>
      <!--/noindex-->
      

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">  <a href="http://www.beian.miit.gov.cn" rel="noopener" target="_blank">苏ICP备17004952号 </a>&copy; <span itemprop="copyrightYear">2020</span>
  <span class="with-love" id="animate">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Crazy Rico</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-area-chart"></i>
    </span>
    <span title="站点总字数">90k</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
    <span title="站点阅读时长">1:22</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io" class="theme-link" rel="noopener" target="_blank">Hexo</a> 强力驱动 v3.9.0</div>
  <span class="post-meta-divider">|</span>
  <div class="theme-info">主题 – <a href="https://theme-next.org" class="theme-link" rel="noopener" target="_blank">NexT.Gemini</a> v7.3.0</div>

        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span class="post-meta-item-icon">
      <i class="fa fa-user"></i>
    </span>
    <span class="site-uv" title="总访客量">
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
    </span>
  
    <span class="post-meta-divider">|</span>
  
    <span class="post-meta-item-icon">
      <i class="fa fa-eye"></i>
    </span>
    <span class="site-pv" title="总访问量">
      <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
    </span>
  
</div>


  <!--
  <div style="display: none;">
    <script src="//s95.cnzz.com/z_stat.php?id=true&web_id=true"></script>
  </div>
  -->
  <script type="text/javascript">var cnzz_protocol = (("https:" == document.location.protocol) ? "https://" : "http://");document.write(unescape("%3Cspan id='cnzz_stat_icon_1278118065'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "s9.cnzz.com/z_stat.php%3Fid%3D1278118065%26online%3D1%26show%3Dline' type='text/javascript'%3E%3C/script%3E"));</script>






        
      </div>
    </footer>
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
          <span id="scrollpercent"><span>0</span>%</span>
        
      </div>

    

  </div>

  
  <script src="/lib/jquery/index.js?v=3.4.1"></script>
  <script src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  <script src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

<script src="/js/utils.js?v=7.3.0"></script>
  <script src="/js/motion.js?v=7.3.0"></script>


  <script src="/js/affix.js?v=7.3.0"></script>
  <script src="/js/schemes/pisces.js?v=7.3.0"></script>



<script src="/js/next-boot.js?v=7.3.0"></script>






  















  <script src="/js/local-search.js?v=7.3.0"></script>













<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.css">

<script>
  NexT.utils.getScript('//cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js', function() {
    var gitalk = new Gitalk({
      clientID: '9255016b522a1b91949f',
      clientSecret: 'a0344ceccbd072ddf864ace66c89f73e53bfb671',
      repo: 'CrazyRico.github.io',
      owner: 'CrazyRico',
      admin: ['CrazyRico'],
      id: '516a35d265e49707e113184afbcbb8c8',
        language: window.navigator.language || window.navigator.userLanguage,
      
      distractionFreeMode: 'true'
    });
    gitalk.render('gitalk-container');
  }, window.Gitalk);
</script>




  

  

  


  
  <script src="/js/scrollspy.js?v=7.3.0"></script>
<script src="/js/post-details.js?v=7.3.0"></script>


    
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.css">

<script>
  NexT.utils.getScript('//cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js', function() {
    var gitalk = new Gitalk({
      clientID: '9255016b522a1b91949f',
      clientSecret: 'a0344ceccbd072ddf864ace66c89f73e53bfb671',
      repo: 'CrazyRico.github.io',
      owner: 'CrazyRico',
      admin: ['CrazyRico'],
      id: '2e64d459400a09ed39f36b8c402a04e6',
        language: window.navigator.language || window.navigator.userLanguage,
      
      distractionFreeMode: 'true'
    });
    gitalk.render('gitalk-container');
  }, window.Gitalk);
</script>

</body>
</html>
